\(\int \frac {1}{\sqrt {a+b \cot ^2(c+d x)}} \, dx\) [34]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [F(-2)]
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 16, antiderivative size = 47 \[ \int \frac {1}{\sqrt {a+b \cot ^2(c+d x)}} \, dx=-\frac {\arctan \left (\frac {\sqrt {a-b} \cot (c+d x)}{\sqrt {a+b \cot ^2(c+d x)}}\right )}{\sqrt {a-b} d} \]

[Out]

-arctan(cot(d*x+c)*(a-b)^(1/2)/(a+b*cot(d*x+c)^2)^(1/2))/d/(a-b)^(1/2)

Rubi [A] (verified)

Time = 0.05 (sec) , antiderivative size = 47, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.188, Rules used = {3742, 385, 209} \[ \int \frac {1}{\sqrt {a+b \cot ^2(c+d x)}} \, dx=-\frac {\arctan \left (\frac {\sqrt {a-b} \cot (c+d x)}{\sqrt {a+b \cot ^2(c+d x)}}\right )}{d \sqrt {a-b}} \]

[In]

Int[1/Sqrt[a + b*Cot[c + d*x]^2],x]

[Out]

-(ArcTan[(Sqrt[a - b]*Cot[c + d*x])/Sqrt[a + b*Cot[c + d*x]^2]]/(Sqrt[a - b]*d))

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 385

Int[((a_) + (b_.)*(x_)^(n_))^(p_)/((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Subst[Int[1/(c - (b*c - a*d)*x^n), x]
, x, x/(a + b*x^n)^(1/n)] /; FreeQ[{a, b, c, d}, x] && NeQ[b*c - a*d, 0] && EqQ[n*p + 1, 0] && IntegerQ[n]

Rule 3742

Int[((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_), x_Symbol] :> With[{ff = FreeFactors[Tan[e + f*x]
, x]}, Dist[c*(ff/f), Subst[Int[(a + b*(ff*x)^n)^p/(c^2 + ff^2*x^2), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ
[{a, b, c, e, f, n, p}, x] && (IntegersQ[n, p] || IGtQ[p, 0] || EqQ[n^2, 4] || EqQ[n^2, 16])

Rubi steps \begin{align*} \text {integral}& = -\frac {\text {Subst}\left (\int \frac {1}{\left (1+x^2\right ) \sqrt {a+b x^2}} \, dx,x,\cot (c+d x)\right )}{d} \\ & = -\frac {\text {Subst}\left (\int \frac {1}{1-(-a+b) x^2} \, dx,x,\frac {\cot (c+d x)}{\sqrt {a+b \cot ^2(c+d x)}}\right )}{d} \\ & = -\frac {\arctan \left (\frac {\sqrt {a-b} \cot (c+d x)}{\sqrt {a+b \cot ^2(c+d x)}}\right )}{\sqrt {a-b} d} \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(111\) vs. \(2(47)=94\).

Time = 0.48 (sec) , antiderivative size = 111, normalized size of antiderivative = 2.36 \[ \int \frac {1}{\sqrt {a+b \cot ^2(c+d x)}} \, dx=-\frac {\text {arctanh}\left (\frac {\sqrt {-\frac {(a-b) \cot ^2(c+d x)}{a}}}{\sqrt {1+\frac {b \cot ^2(c+d x)}{a}}}\right ) \cot (c+d x) \sqrt {1+\frac {b \cot ^2(c+d x)}{a}}}{d \sqrt {-\frac {(a-b) \cot ^2(c+d x)}{a}} \sqrt {a+b \cot ^2(c+d x)}} \]

[In]

Integrate[1/Sqrt[a + b*Cot[c + d*x]^2],x]

[Out]

-((ArcTanh[Sqrt[-(((a - b)*Cot[c + d*x]^2)/a)]/Sqrt[1 + (b*Cot[c + d*x]^2)/a]]*Cot[c + d*x]*Sqrt[1 + (b*Cot[c
+ d*x]^2)/a])/(d*Sqrt[-(((a - b)*Cot[c + d*x]^2)/a)]*Sqrt[a + b*Cot[c + d*x]^2]))

Maple [A] (verified)

Time = 0.11 (sec) , antiderivative size = 68, normalized size of antiderivative = 1.45

method result size
derivativedivides \(-\frac {\sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (d x +c \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (d x +c \right )^{2}}}\right )}{d \,b^{2} \left (a -b \right )}\) \(68\)
default \(-\frac {\sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (d x +c \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (d x +c \right )^{2}}}\right )}{d \,b^{2} \left (a -b \right )}\) \(68\)

[In]

int(1/(a+b*cot(d*x+c)^2)^(1/2),x,method=_RETURNVERBOSE)

[Out]

-1/d*(b^4*(a-b))^(1/2)/b^2/(a-b)*arctan(b^2*(a-b)/(b^4*(a-b))^(1/2)/(a+b*cot(d*x+c)^2)^(1/2)*cot(d*x+c))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 90 vs. \(2 (41) = 82\).

Time = 0.31 (sec) , antiderivative size = 239, normalized size of antiderivative = 5.09 \[ \int \frac {1}{\sqrt {a+b \cot ^2(c+d x)}} \, dx=\left [-\frac {\sqrt {-a + b} \log \left (-2 \, {\left (a^{2} - 2 \, a b + b^{2}\right )} \cos \left (2 \, d x + 2 \, c\right )^{2} - 2 \, {\left ({\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) - b\right )} \sqrt {-a + b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) - a - b}{\cos \left (2 \, d x + 2 \, c\right ) - 1}} \sin \left (2 \, d x + 2 \, c\right ) + a^{2} - 2 \, b^{2} + 4 \, {\left (a b - b^{2}\right )} \cos \left (2 \, d x + 2 \, c\right )\right )}{4 \, {\left (a - b\right )} d}, -\frac {\arctan \left (-\frac {\sqrt {a - b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) - a - b}{\cos \left (2 \, d x + 2 \, c\right ) - 1}} \sin \left (2 \, d x + 2 \, c\right )}{{\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) - b}\right )}{2 \, \sqrt {a - b} d}\right ] \]

[In]

integrate(1/(a+b*cot(d*x+c)^2)^(1/2),x, algorithm="fricas")

[Out]

[-1/4*sqrt(-a + b)*log(-2*(a^2 - 2*a*b + b^2)*cos(2*d*x + 2*c)^2 - 2*((a - b)*cos(2*d*x + 2*c) - b)*sqrt(-a +
b)*sqrt(((a - b)*cos(2*d*x + 2*c) - a - b)/(cos(2*d*x + 2*c) - 1))*sin(2*d*x + 2*c) + a^2 - 2*b^2 + 4*(a*b - b
^2)*cos(2*d*x + 2*c))/((a - b)*d), -1/2*arctan(-sqrt(a - b)*sqrt(((a - b)*cos(2*d*x + 2*c) - a - b)/(cos(2*d*x
 + 2*c) - 1))*sin(2*d*x + 2*c)/((a - b)*cos(2*d*x + 2*c) - b))/(sqrt(a - b)*d)]

Sympy [F]

\[ \int \frac {1}{\sqrt {a+b \cot ^2(c+d x)}} \, dx=\int \frac {1}{\sqrt {a + b \cot ^{2}{\left (c + d x \right )}}}\, dx \]

[In]

integrate(1/(a+b*cot(d*x+c)**2)**(1/2),x)

[Out]

Integral(1/sqrt(a + b*cot(c + d*x)**2), x)

Maxima [F(-2)]

Exception generated. \[ \int \frac {1}{\sqrt {a+b \cot ^2(c+d x)}} \, dx=\text {Exception raised: ValueError} \]

[In]

integrate(1/(a+b*cot(d*x+c)^2)^(1/2),x, algorithm="maxima")

[Out]

Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'a
ssume' command before evaluation *may* help (example of legal syntax is 'assume(b-a>0)', see `assume?` for mor
e details)Is

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 97 vs. \(2 (41) = 82\).

Time = 1.32 (sec) , antiderivative size = 97, normalized size of antiderivative = 2.06 \[ \int \frac {1}{\sqrt {a+b \cot ^2(c+d x)}} \, dx=\frac {2 \, \arctan \left (-\frac {\sqrt {b} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - \sqrt {b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{4} + 4 \, a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 2 \, b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + b} + \sqrt {b}}{2 \, \sqrt {a - b}}\right )}{\sqrt {a - b} d \mathrm {sgn}\left (\sin \left (d x + c\right )\right )} \]

[In]

integrate(1/(a+b*cot(d*x+c)^2)^(1/2),x, algorithm="giac")

[Out]

2*arctan(-1/2*(sqrt(b)*tan(1/2*d*x + 1/2*c)^2 - sqrt(b*tan(1/2*d*x + 1/2*c)^4 + 4*a*tan(1/2*d*x + 1/2*c)^2 - 2
*b*tan(1/2*d*x + 1/2*c)^2 + b) + sqrt(b))/sqrt(a - b))/(sqrt(a - b)*d*sgn(sin(d*x + c)))

Mupad [B] (verification not implemented)

Time = 13.73 (sec) , antiderivative size = 41, normalized size of antiderivative = 0.87 \[ \int \frac {1}{\sqrt {a+b \cot ^2(c+d x)}} \, dx=-\frac {\mathrm {atan}\left (\frac {\mathrm {cot}\left (c+d\,x\right )\,\sqrt {a-b}}{\sqrt {b\,{\mathrm {cot}\left (c+d\,x\right )}^2+a}}\right )}{d\,\sqrt {a-b}} \]

[In]

int(1/(a + b*cot(c + d*x)^2)^(1/2),x)

[Out]

-atan((cot(c + d*x)*(a - b)^(1/2))/(a + b*cot(c + d*x)^2)^(1/2))/(d*(a - b)^(1/2))